package com.zhangj.alljvm.oom;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName OutOfMemoryErrorTest04
 * @Description
 * @Author zhangjie
 * @Date 2022/3/14 8:25
 * @Version 1.0
 */
public class OutOfMemoryErrorTest04 {
    public static void main(String[] args) {

/*        Thread thread = new Thread();

        thread.start();
        thread.start();  //Exception in thread "main" java.lang.IllegalThreadStateException*/
       //ConcurrentHashMap

        //注意啊,这个一跑基本就会死机,启动前想清楚啊,该保存的保存一下
        for (int i = 1; ; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "我被创建");
                //保证线程一定不销毁
                try {
                     TimeUnit.SECONDS.sleep(Integer.MAX_VALUE);
                } catch (InterruptedException e) {
                     e.printStackTrace();
                }
            }, "线程" + i + ": ").start();
        }


    }
}
